Skip to content

gh-155519: fix data-race for Context.ctx_vars - #155522

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
nascheme:gh-155519-ctx-vars-race
Aug 15, 2026
Merged

gh-155519: fix data-race for Context.ctx_vars#155522
kumaraditya303 merged 2 commits into
python:mainfrom
nascheme:gh-155519-ctx-vars-race

Conversation

@nascheme

@nascheme nascheme commented Aug 10, 2026

Copy link
Copy Markdown
Member

The HAMT held by a context is immutable, but the pointer to it is not: contextvar_set() and contextvar_del() install a new HAMT and drop the reference to the previous one. Use critical sections to ensure ordering in the free-threaded build.

The HAMT held by a context is immutable, but the pointer to it is not:
contextvar_set() and contextvar_del() install a new HAMT and drop the
reference to the previous one.  Use critical sections to ensure
ordering in the free-threaded build.
@kumaraditya303
kumaraditya303 merged commit 9ee248c into python:main Aug 15, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants